package com.chazz.utils;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;

import java.util.ArrayList;
import java.util.List;

public class JSONUtils {

    /**
     *
     * @param <T>
     * @return
     */
    public static <T> List<T> toList(Class<T> clazz,String content){
        List<T> list = new ArrayList<>();
        JSONArray objects = JSONArray.parseArray(content);
        for(int i = 0 ;i < objects.size();i++){
            T t = JSON.parseObject(objects.getJSONObject(i).toJSONString(),clazz);
            list.add(t);
        }
        return list;
    }

}
